<?php require_once('../Connections/miportal.php'); ?>
<?php require_once('../Connections/miportal.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../private/login.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../private/login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php require_once('../Connections/miportal.php'); 
mysql_query("SET NAMES 'utf8'");?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$ies_rsCarreras = "-1";
if (isset($_SESSION['MM_id_target'])) {
  $ies_rsCarreras = $_SESSION['MM_id_target'];
}
mysql_select_db($database_miportal, $miportal);
$query_rsCarreras = sprintf("SELECT id_cat_carrera, cve_carrera, nmb_carrera, id_institucional FROM cat_carrera JOIN cat_ies USING (id_institucional) WHERE id_cat_ies=%s", GetSQLValueString($ies_rsCarreras, "int"));
$rsCarreras = mysql_query($query_rsCarreras, $miportal) or die(mysql_error());
$row_rsCarreras = mysql_fetch_assoc($rsCarreras);
$totalRows_rsCarreras = mysql_num_rows($rsCarreras);

$colname_rsDocumentos = "-1";
if (isset($_GET['id_cor_candidato'])) {
  $colname_rsDocumentos = $_GET['id_cor_candidato'];
}
$colname_rsConvocatoria = "-1";
if (isset($_GET['id_convocatoria'])) {
  $colname_rsConvocatoria = $_GET['id_convocatoria'];
}
mysql_select_db($database_miportal, $miportal);
$query_rsDocumentos = sprintf("SELECT eval_curp, eval_rfc, eval_seguro, eval_constancia, eval_carta FROM cor_expediente WHERE id_cor_candidato = %s AND id_cat_convocatoria=%s", GetSQLValueString($colname_rsDocumentos, "int"),GetSQLValueString($colname_rsConvocatoria, "int"));
$rsDocumentos = mysql_query($query_rsDocumentos, $miportal) or die(mysql_error());
$row_rsDocument = mysql_fetch_assoc($rsDocumentos);
$totalRows_rsDocumentos = mysql_num_rows($rsDocumentos);

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$tp_status_rev=0;

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "formRegCandidatoExpediente")) {
	$suma_val=
   (GetSQLValueString(isset($_POST['EVALUACION_0']) ? "true" : "", "defined","1","0")+
                       GetSQLValueString(isset($_POST['EVALUACION_1']) ? "true" : "", "defined","1","0")+
                       GetSQLValueString(isset($_POST['EVALUACION_2']) ? "true" : "", "defined","1","0")+
                       GetSQLValueString(isset($_POST['EVALUACION_3']) ? "true" : "", "defined","1","0")+
                       GetSQLValueString(isset($_POST['EVALUACION_4']) ? "true" : "", "defined","1","0"));	
	if($suma_val==2 &&$_POST['id_cat_convocatoria']==20 )
	{
		$tp_status_rev=1;
	}else if($suma_val==4 &&($_POST['id_cat_convocatoria']==17||$_POST['id_cat_convocatoria']==18 )){
		$tp_status_rev=1;
	}else if($suma_val==5 &&$_POST['id_cat_convocatoria']<=19 ){
		$tp_status_rev=1;
	}else{
	$tp_status_rev=-1;
	}

	
  $updateSQL = sprintf("UPDATE cor_expediente SET eval_fecha_evaluacion=NOW(),eval_curp=%s, eval_constancia=%s, eval_carta=%s, eval_rfc=%s, eval_seguro=%s, eval_comentario=%s,  eval_revisor=%s,  tp_status_eval=%s WHERE id_cor_candidato=%s AND id_cat_convocatoria=%s",
                       GetSQLValueString(isset($_POST['EVALUACION_0']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['EVALUACION_1']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['EVALUACION_2']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['EVALUACION_3']) ? "true" : "", "defined","1","0"),
                       GetSQLValueString(isset($_POST['EVALUACION_4']) ? "true" : "", "defined","1","0"),
					   GetSQLValueString($_POST['EVALUACION_COMENTARIO'], "text"),
					   GetSQLValueString($_SESSION['MM_UsName'], "text"),
					   GetSQLValueString($tp_status_rev),
                       GetSQLValueString($_POST['id_cor_beneficiario'], "int"),
                       GetSQLValueString($_POST['id_cat_convocatoria'], "int"));

  mysql_select_db($database_miportal, $miportal);
  $Result1 = mysql_query($updateSQL, $miportal) or die(mysql_error().$updateSQL);

  $updateGoTo = "../report/report_dva_candidatos.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
   echo'
  <script type="text/javascript">
		 window.location="../report/report_dva_candidatos.php";
  </script>';

  //header(sprintf("Location: %s", $updateGoTo));
}
 ?>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximun-scale=1">
<title>FUNDACIÓN EDUCACIÓN SUPERIOR-EMPRESA</title>
<!--Hoja de estilo principal-->
<link href="../css/styletd2.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="../css/mos-style.css">
<link rel="stylesheet" type="text/css" href="../css/menu.css">
<link href="../SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css">
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<!--Pemanggilan gambar favicon-->
 <!--pemanggilan file css-->
<script src="../SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script language=""="JavaScript">
	function conMayusculas(field) {
				field.value = field.value.toUpperCase()
		}
	function confirmar ( mensaje ) {
					return confirm( mensaje );
				}
        </script>
        
<script><!--SCRIPT AJAX MUNICIPIO-->
	function showMunicipio(str)
	{
		if (str=="")
		  {
		  document.getElementById("municipio").innerHTML="";
		  return;
		  } 
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	  }
		xmlhttp.onreadystatechange=function()
		  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("municipio").innerHTML=xmlhttp.responseText;
			}
	  }
	xmlhttp.open("GET","../lib/utils/getMunicipio.php?q="+str,true);
	xmlhttp.send();
	}
</script>     
<script><!--SCRIPT AJAX Carrera-->
	function showCarrera(str)
	{
		if (str=="")
		  {
		  document.getElementById("insCarrera").innerHTML="";
		  return;
		  } 
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	  }
		xmlhttp.onreadystatechange=function()
		  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("insCarrera").innerHTML=xmlhttp.responseText;
			}
	  }
	xmlhttp.open("GET","../lib/utils/getCarrera.php?q="+str,true);
	xmlhttp.send();
	}
</script>   
<script><!--SCRIPT AJAX Otra Carrera-->
	function showOtraCarrera(str)
	{
		if (str=="")
		  {
		  document.getElementById("OtraCarrera").innerHTML="";
		  return;
		  } 
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	  }
		xmlhttp.onreadystatechange=function()
		  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				document.getElementById("OtraCarrera").innerHTML=xmlhttp.responseText;
			}
	  }
	xmlhttp.open("GET","../lib/utils/getOtraCarrera.php?q="+str,true);
	xmlhttp.send();
	}
</script>  
<link href="../SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css">
<link href="../SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css">
</head>
<body>



 
 <header>
    <div id="background"></div>
    <div class="img_header_logo"></div>
    <span class="img_header_logo"><a href="http://fese.org.mx"><img src="../images/fese/FESE_home_logo.png"  height="90" alt="FESE" align="bottom" /></a></span>
    <div class="img_header_logo"></div>
    
  
<div id="nav">
<ul>
  <li class="nivel1"><a href="../private/dva.php" class="nivel1">Inicio</a></li>
  <li class="nivel1"><a href="../report/report_dva_candidatos.php" class="nivel1">Candidatos</a></li>
  <?php if($_SESSION['MM_tp_programa']!="MI PRIMERA EMPRESA"){
			  echo 
			  		'<li class="nivel1"><a href="../report/report_dva_empresa.php" class="nivel1">Empresas</a></li>';
			 		 }	
		  
		  ?>
	
</ul>
</div><!--Menu NAV-->

</header>

<center>
<div id="boxcontainer">
<div id="container">
<h2>EVALUACIÓN  DE EXPEDIENTE: </h2>
<form action="<?php echo $editFormAction; ?>" method="POST" name="formRegCandidatoExpediente">
<table name="t_candidato" min-width="620px" border="1" style="margin:0 auto; padding-left:5%;">
	<tr>
    <?php if(isset($_GET['id_ies'])&&isset($_GET['id_convocatoria'])&&isset($_GET['id_cor_candidato'])){?>
	  <td colspan="2">
        <input type="hidden" name="id_ies" id="id_ies" value="<?php echo $_GET['id_ies'];?>">
	    <input type="hidden" name="id_cat_convocatoria" id="id_cat_convocatoria" value="<?php echo $_GET['id_convocatoria'];?>">
	    <input type="hidden" name="id_cor_beneficiario" id="id_cor_beneficiario" value="<?php echo $_GET['id_cor_candidato'];?>">
      </td>
      <?php } ?>
	  </tr>
	<tr>
	  <td><p>
	    <label>
	      <input type="checkbox" name="EVALUACION_0" value="0" id="EVALUACION_0" <?php if($row_rsDocument['eval_curp']==1){echo 'checked=""';}?> >CURP
          </label>
	    <br>
	    <label>
	      <input type="checkbox" name="EVALUACION_1" value="0" id="EVALUACION_1" <?php if( $row_rsDocument['eval_constancia']==1){echo 'checked=""';}?> >CONSTANCIA
          </label>
	    <br>
	    <label <?php if($_GET['id_convocatoria']>19){echo 'style="visibility:hidden"';}else{echo 'style="visibility:visible"';}?>>
	      <input type="checkbox" name="EVALUACION_2" value="0" id="EVALUACION_2"  <?php if($row_rsDocument['eval_carta']==1){echo 'checked=""';}?>  >CARTA DE LA EMPRESA
          </label>
          <br>
	    <label <?php if($_GET['id_convocatoria']>19){echo 'style="visibility:hidden"';}else{echo 'style="visibility:visible"';}?>>
        <input type="checkbox" name="EVALUACION_3" value="0" id="EVALUACION_3"  <?php if( $row_rsDocument['eval_rfc']==1){echo 'checked=""';}?>>RFC DE LA EMPRESA
        </label>
	    <br>
	    <label  <?php if($_GET['id_convocatoria']!=19){echo 'style="visibility:hidden"';}else{echo 'style="visibility:visible"';}?>>
	      <input type="checkbox" name="EVALUACION_4" value="0" id="EVALUACION_4"  <?php if($row_rsDocument['eval_seguro']==1){echo 'checked=""';}?>>SEGURO MÉDICO
          </label>
	    </p>
	    <p><span id="sprytextarea1">
	      <label>COMENTARIOS
	        <textarea name="EVALUACION_COMENTARIO" cols="100" rows="20" id="EVALUACION_COMENTARIO"></textarea>
	        </label>
	      <span class="textareaRequiredMsg">Se necesita un valor.</span></span><br>
	      </p></td>
	  <td><p><br>
	    </p>	    <span id="entidad"><span class="selectRequiredMsg">Seleccione un elemento.</span></span>
	    <p><br>
	      </p></td>
	  </tr>
	<!--<tr>
		<td>Area de conocimiento</td>
		<td><span id="area">
		  <select name="areaConocimiento" onChange="showCarrera(this.value)">
		    <option value="" selected="selected">Seleccione</option>
		    <option value="366">EDUCACIÓN</option>
		    <option value="02">ARTES Y HUMANIDADES</option>
		    <option value="03">CIENCIAS SOCIALES, ADMINISTRACIÓN Y DERECHO</option>
		    <option value="04">CIENCIAS NATURALES, EXACTAS Y DE LA COMUTACIÓN</option>
		    <option value="05">INGENIERIA, MANUFACTURAS Y CONSTRUCCIÓN</option>
		    <option value="06">AGRONOMIA Y VETERINARIA</option>
		    <option value="07">SALUD</option>
		    <option value="08">SERVICIOS</option>
		    </select>
		  <br>
		  <span class="selectRequiredMsg">Seleccione un elemento.</span></span></td>
	</tr>-->
	<tr>
	  <td colspan="2" style="text-align:right">&nbsp;</td>
	  </tr>
	<tr>
	  <td colspan="2" style="text-align:right"><input type="submit" class="button" value="Guardar y continuar" onClick="return confirmar('¿Esta seguro que desea guardar la selección?')"></td>
	  </tr>
</table>
<input type="hidden" name="MM_insert" value="formRegCandidatoExpediente">
<input type="hidden" name="MM_update" value="formRegCandidatoExpediente">
</form>
</div>
<!--Container-->
<div id="rightContainer">
    <div id="Bienvenida">
    <div id="cuadro">
    <h1>Bienvenido</h1>
    </div>
    
    <div >
    <br>
            <?php echo $_SESSION['MM_UsName'] ?><br><br>
            <?php echo $_SESSION['MM_nmb_target'] ?><br>
            <a href="<?php echo $logoutAction ?>">Salir</a>
        </div>
    </div>
    <br style="clear:both"/>
    <div id="convocatoria">
    <div id="cuadro">
    <h1>Convocatoria</h1>
    </div>
    <br>
    <?php 
    if(isset($_SESSION['MM_tp_programa'])&$_SESSION['MM_tp_programa']=="Vigentes"){
        echo "<select name=\"slConvocatoria\">
        <option selected=\"selected\">Seleccione</option>
        <option value=\"empleate\">Empleate</option>
        <option value=\"experimenta\">Experimenta</option>
        <option value=\"mpe\">Mi Primera Empresa</option>
        <option value=\"vecas_vinculacion\">Vecas Vinculación</option>
        </select>
        "	;
    }else{
    echo $_SESSION['MM_tp_programa'];}
    ?>
    
    </div>
</div><!--contenedor derecho-->


</div><!--Boxcontainer-->
  
   
</center>
<script type="text/javascript">
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur", "change"], hint:"Ingresa tus observaciones."});
</script>
</body>
</html>
<?php
mysql_free_result($rsCarreras);

mysql_free_result($rsDocumentos);
?>
